home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group98a.txt
/
000080_icon-group-sender _Mon Mar 2 16:43:13 1998.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
3KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by baskerville.CS.Arizona.EDU (8.8.7/8.8.7) with SMTP id QAA01578
for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Mon, 2 Mar 1998 16:43:12 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA03768; Mon, 2 Mar 1998 16:43:11 -0700
Date: Mon, 2 Mar 1998 22:11:43 +0300 (MEST)
From: Ehud Lamm <mslamm@mscc.huji.ac.il>
To: icon-group@optima.CS.Arizona.EDU
Subject: Optimzing Icon
Message-Id: <Pine.A32.3.91.980302215824.39794B-100000@pluto.mscc.huji.ac.il>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Content-Length: 2352
The recent thread about compiling Icon into C raised the question of
optimizing the resulting C code.
The are two aspect worth thinking about here:
1. What Icon programs and constructs are more efficient (from a
computer's standpoint. NOT programmer time).
2. How should you implement, in the best possible way, an Icon construct
in C (or machine language for that matter).
Question 1, refers to things like type usage (less conversions are good,
regardless of interpretation or compilation of the program), use of good
data structures (and using them consistently as lists/queue etc.), good
use of string scanning and things of this sort.
These aspects are crucial if you paln to produce an optimizing compiler,
because knowing which constructs are better allows you to optimize their
use to good machine level code. It also allows you to perform some
check/transformations at the front end of the compiler.
Question 2, is less Icon dependent, and more C-oriented or specific to
the machine targeted. It is based on the fact that in order to produce
good code, you have to know what kinds of operations are fast, and by how
much. Good (==fast) low level code relies on understanding the cost of
operations.
When you write a translator to C you have to be good at C... For
exampleit is common to note that the strlen function in C is not fast,
since it has to scan the entire string in order to find its length. This
is becasuse the way C handles strings (as null terminated vectors of
characters). It is a well known tip that if you process a C string in
a loop you should strlen at each iteration, but rather keep a local
variable with the length (obtained by strlen outside the loop), and
upadate when you update the string.
This common technique for example, is something to keep in mind when you
translate a string dominated program to C.
Of course you have other options (like coding you own string hanlding
libray. An option with obvious drawbacks), which may not be directly
relevent to the Icnon->C compiler. But this is just an example. There
are dozens of such optimizations possible.
An optimzing compiler can not find you a better algorithm, to solve your
problem - but it will usually produce better low level code. This is a
well known truth...
Ehud Lamm mslamm@pluto.mscc.huji.ac.il